<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app">
    <home></home>
    
  </div>


  <script src="./vue.js"></script>
  <script>
    const Child = {
      template: `
        <div>
          <h3>我是子组件头部</h3>
          <slot :data1="arr" :data2="msg"></slot>
          <h3>我是子组件foot</h3>
        </div>
      `,
      data(){
        return {
          arr: ['a','b','c','d'],
          msg: '我是子组件数据'
        }
      }
    }
    const Home = {
      template: `
        <div>
          <h2>我是父组件1</h2>
          <child>
            <div slot-scope="scope">
              <ul>
                <li v-for="item in scope.data1" :key="item">
                  {{ item }}  
                </li>  
              </ul>
              <button>{{scope.data2}}</button>  
            </div>  
          </child>
        </div>
      `,
      data(){
        return {
          msg: '我是父组件中定义的动态数据'
        }
      },
      components: {
        Child
      }
    }
    Vue.component('Home', Home);
    
    const vm = new Vue({
      el: '#app',
      data: {

      }
    })
  </script>
</body>

</html>